using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TestPostion : MonoBehaviour
{
    void Start()
    {
        var canvas = GameObject.Find("Canvas");
        var uiRoot = canvas.GetComponent<RectTransform>();
        Vector2 screenPos = RectTransformUtility.WorldToScreenPoint(Camera.main, transform.position);
        Vector2 center;
        RectTransformUtility.ScreenPointToLocalPointInRectangle(uiRoot, screenPos, Camera.main, out center);
        Debug.Log(gameObject.name+" 相对于canvas位置："+center);
    }
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Debug.Log(gameObject.name+" 位置localpostion："+transform.localPosition);
        }
    }
}
